package com.binest.investorInclusion.controller;



import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.core.page.TableDataInfo;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.investorInclusion.domain.InvestorInclusion;
import com.binest.investorInclusion.domain.JointInvestment;
import com.binest.investorInclusion.service.IInvestorInclusionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投资机构收录Controller
 * 
 * @author wwd
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/investorInclusion")
public class InvestorInclusionController extends BaseController
{
    @Autowired
    private IInvestorInclusionService investorInclusionService;

    /**
     * 查询投资机构收录列表
     */

    @GetMapping("/list")
    public TableDataInfo list(InvestorInclusion investorInclusion)
    {
        startPage();
        List<InvestorInclusion> list = investorInclusionService.selectInvestorInclusionList(investorInclusion);
        return getDataTable(list);
    }

    @GetMapping("/getjointInvestmentList")
    public TableDataInfo getjointInvestmentList(String id ,String lang) throws Exception {
        startPage();
        List<JointInvestment> list = investorInclusionService.selectJointInvestmentList(id,lang);
        return getDataTable(list);
    }



    /**
     * 查询es中投资机构收录列表
     */
    @GetMapping("/esList")
    public TableDataInfo esList(InvestorInclusion investorInclusion) throws Exception {

        TableDataInfo list = investorInclusionService.selectInvestorInclusionEsList(investorInclusion);
        return list;
    }

    /**
     *  获取投资概览
     * @param id
     * @param lang
     * @return
     * @throws Exception
     */
    @GetMapping("/getInvestmentSurvey")
    public AjaxResult getInvestmentSurvey(String id, String lang) throws Exception {
        return success(investorInclusionService.getInvestmentSurvey( id,lang));
    }



    /**
     * 导出投资机构收录列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, InvestorInclusion investorInclusion)
    {
        List<InvestorInclusion> list = investorInclusionService.selectInvestorInclusionList(investorInclusion);
        ExcelUtil<InvestorInclusion> util = new ExcelUtil<InvestorInclusion>(InvestorInclusion.class);
        util.exportExcel(response, list, "投资机构收录数据");
    }

    /**
     * 获取投资机构收录详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(investorInclusionService.selectInvestorInclusionById(id));
    }
    /**
     * 获取es中投资机构收录详细信息
     */
    @GetMapping(value = "/getEsInfo")
    public AjaxResult getEsInfo(String id) throws Exception {
        return success(investorInclusionService.selectEsInvestorInclusionById(id));
    }

    /**
     * 新增投资机构收录
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody InvestorInclusion investorInclusion)
    {
        return success(investorInclusionService.insertInvestorInclusion(investorInclusion));
    }

    @PostMapping("/update")
    public AjaxResult update(@RequestBody InvestorInclusion investorInclusion)
    {
        return success(investorInclusionService.insertNewInvestorInclusion(investorInclusion));
    }


    /**
     * 修改投资机构收录
     */

    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody InvestorInclusion investorInclusion)
    {
        return toAjax(investorInclusionService.updateInvestorInclusion(investorInclusion));
    }

    /**
     * 删除投资机构收录
     */

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(investorInclusionService.deleteInvestorInclusionByIds(ids));
    }
}
